<?php

require './init.php';

// You need to set the client email for all campaign operations
$api->client_email = 'client_1+adwords-api-usage@hyperactive.ro';
$operations = array();

// Create campaign geo target structures.
$geoTargetList = $api->CampaignTarget()->newGeoTargetList();
$geoTargetList->campaignId = '79424';

$cityTarget = $geoTargetList->newCityTarget();
$cityTarget->excluded = 'false';
$cityTarget->cityName = 'Bucharest';
$cityTarget->provinceCode = 'B';
$cityTarget->countryCode = 'RO';
$geoTargetList->addTarget($cityTarget);

$countryTarget = $geoTargetList->newCountryTarget();
$countryTarget->excluded = 'false';
$countryTarget->countryCode = 'RO';
$geoTargetList->addTarget($countryTarget);

$operation = $api->CampaignTarget()->newOperation();
$operation->operator = 'SET';
$operation->operand = $geoTargetList;
$operations[] = $operation;


// Create campaign language target structures.
$languageTargetList = $api->CampaignTarget()->newLanguageTargetList();
$languageTargetList->campaignId = '79424';

$langTarget = $languageTargetList->newTarget();
$langTarget->languageCode = 'en';
$languageTargetList->addTarget($langTarget);

$operation = $api->CampaignTarget()->newOperation();
$operation->operator = 'SET';
$operation->operand = $languageTargetList;
$operations[] = $operation;

// Create campaign network target structures.
$networkTargetList = $api->CampaignTarget()->newNetworkTargetList();
$networkTargetList->campaignId = '79424';
$networkTargetList->addTargetType('GOOGLE_SEARCH');
$networkTargetList->addTargetType('SEARCH_NETWORK');


$operation = $api->CampaignTarget()->newOperation();
$operation->operator = 'SET';
$operation->operand = $networkTargetList;
$operations[] = $operation;


// Call API to execute operations
$result = $api->CampaignTarget()->mutate($operations);
var_dump($result);